# def fib(n):  ##n是形参
#     a, b = 1, 1
#     while a < n:
#         print(a, end=' ')
#         a, b = b, a + b
#
# fib(1000)
#
#
# def f():
#     a, b = 1, 1   #序列解包，同时为多个元素赋值
#     while True:
#         yield a   #暂停执⾏，需要时再产⽣⼀个新元素
#         a, b = b, a+b   #序列解包，继续⽣成新元素
# a = f()   #创建⽣成器对象
# for i in range(10):   #斐波那契数列中前10个元素
#     print(next(a), end=' ')
#
#
# def f():
#     a, b = 1, 1
#     while True:
#         yield a
#         a, b = b, a+b
# # 使用 for 循环而不是 next()
# for i, num in enumerate(f()):
#     if i >= 10:  # 只取前10个
#         break
#     print(num, end=' ')

